"""
使用：
	1.使用response设置cookie
		max_age: cookie的有效期时间
		response.set_cookie(key, value, max_age)
		return response
	2.获取cookie
		name = request.cookies.get('name')
	3.删除cookie
		response.delete_cookie(key)
"""
from flask import Flask, make_response, request

app =Flask(__name__)
@app.route('/set_cookie')
def set_cookie():
    # 设置cookie
    response = make_response('index')
    response.set_cookie('name', 'laowang', max_age=30)
    return response
@app.route('/get_cookie')
def get_cookie():
    # 获取cookie
    name = request.cookies.get('name')
    return 'get_cookie:{}'.format(name)
@app.route('/delete_cookie')
def delete_cookie():
    # 删除cookie
    response = make_response('ok')
    response.delete_cookie('name')
    return response

if __name__ == '__main__':
    app.run(debug=True)